]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/backlight: Fix a11y label of discrete level buttons
authorFlorian Müllner <fmuellner@gnome.org>
Tue, 12 Nov 2024 23:51:22 +0000 (00:51 +0100)
committerMarge Bot <marge-bot@gnome.org>
Wed, 13 Nov 2024 12:32:57 +0000 (12:32 +0000)
Point the discrete level buttons to the corresponding labels,
so that they don't appear as plain "button" in screen readers.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3545>

js/ui/status/backlight.js

index b39cfa632a7fb53be31353cc93bd926b8fbe7501..d43e1ee45c93d73cf498601e628f76d5c0714dce 100644 (file)
@@ -106,17 +106,23 @@ const DiscreteItem = GObject.registerClass({
         return 100 * Math.min(keyIndex, this.nLevels - 1) / (this.nLevels - 1);
     }
 
-    _addLevelButton(key, label, iconName) {
+    _addLevelButton(key, labelText, iconName) {
         const box = new St.BoxLayout({
             style_class: 'keyboard-brightness-level',
             vertical: true,
             x_expand: true,
         });
 
+        const label = new St.Label({
+            text: labelText,
+            x_align: Clutter.ActorAlign.CENTER,
+        });
+
         box.button = new St.Button({
             styleClass: 'icon-button',
             canFocus: true,
             iconName,
+            labelActor: label,
         });
         box.add_child(box.button);
 
@@ -124,10 +130,7 @@ const DiscreteItem = GObject.registerClass({
             this.value = this._levelToValue(key);
         });
 
-        box.add_child(new St.Label({
-            text: label,
-            x_align: Clutter.ActorAlign.CENTER,
-        }));
+        box.add_child(label);
 
         this.add_child(box);
         this._levelButtons.set(key, box);